<!DOCTYPE html>
<script src="../include.js"></script>
<script src="gamepad-helper.js"></script>
<script>
    asyncTest(async (done) => {
        println(`Initial: ${getStringifiedGamepads()}`);

        const gamepad = internals.connectVirtualGamepad();
        await handleSDLInputEvents();
        listenForGamepadConnected();

        println(`Before user gesture of pressing a button: ${getStringifiedGamepads()}`);
        gamepad.setButton(gamepad.buttons[0], true);
        await handleSDLInputEvents();
        println(`After user gesture of pressing a button: ${getStringifiedGamepads()}`);

        listenForGamepadDisconnected();
        gamepad.disconnect();
        await handleSDLInputEvents();
        done();
    });
</script>
